<rd-header>
  <rd-header-title title-text="Storidge cluster">
    <a data-toggle="tooltip" title="Refresh" ui-sref="storidge.cluster" ui-sref-opts="{reload: true}">
      <i class="fa fa-sync" aria-hidden="true"></i>
    </a>
  </rd-header-title>
  <rd-header-content>
    <a ui-sref="storidge.cluster">Storidge</a>
  </rd-header-content>
</rd-header>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-bolt" title-text="Cluster details"></rd-widget-header>
      <rd-widget-body>
        <table class="table">
          <tbody>
            <tr>
              <td>Domain</td>
              <td>{{ clusterInfo.Domain }}</td>
            </tr>
            <tr>
              <td>Status</td>
              <td><i class="fa fa-heartbeat space-right green-icon"></i> {{ clusterInfo.Status }}</td>
            </tr>
            <tr>
              <td>Version</td>
              <td>{{ clusterVersion }}</td>
            </tr>
          </tbody>
        </table>
        <form class="form-horizontal">
          <div class="col-sm-12 form-section-title">
            Actions
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <button type="button" class="btn btn-danger btn-sm" ng-click="shutdownCluster()" ng-disabled="state.shutdownInProgress" button-spinner="state.shutdownInProgress">
                <span ng-hide="state.shutdownInProgress"><i class="fa fa-power-off space-right" aria-hidden="true"></i> Shutdown the cluster</span>
                <span ng-show="state.shutdownInProgress">Shutting down cluster...</span>
              </button>
              <button type="button" class="btn btn-danger btn-sm" ng-click="rebootCluster()" ng-disabled="state.rebootInProgress" button-spinner="state.shutdownInProgress">
                <span ng-hide="state.rebootInProgress"><i class="fa fa-sync space-right" aria-hidden="true"></i> Reboot the cluster</span>
                <span ng-show="state.rebootInProgress">Rebooting cluster...</span>
              </button>
            </div>
          </div>
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row">
  <div class="col-sm-12">
    <storidge-nodes-datatable
    title-text="Storage nodes" title-icon="fa-object-group"
    dataset="clusterNodes" table-key="storidge_nodes"
    order-by="Name" 
    ></storidge-nodes-datatable>
  </div>
</div>

<!-- <div class="row" ng-if="clusterInfo">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-object-group" title-text="Storage nodes">
        <div class="pull-right">
          Items per page:
          <select ng-model="state.pagination_count" ng-change="changePaginationCount()">
            <option value="0">All</option>
            <option value="10">10</option>
            <option value="25">25</option>
            <option value="50">50</option>
            <option value="100">100</option>
          </select>
        </div>
      </rd-widget-header>
      <rd-widget-taskbar classes="col-lg-12">
        <div class="pull-right">
          <input type="text" id="filter" ng-model="state.filter" placeholder="Filter..." class="form-control input-sm" />
        </div>
      </rd-widget-taskbar>
      <rd-widget-body classes="no-padding">
        <div class="table-responsive">
          <table class="table table-hover">
            <thead>
              <tr>
                <th>
                  <a ng-click="order('Name')">
                    Name
                    <span ng-show="sortType == 'Name' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                    <span ng-show="sortType == 'Name' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                  </a>
                </th>
                <th>
                  <a ng-click="order('IP')">
                    IP address
                    <span ng-show="sortType == 'IP' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                    <span ng-show="sortType == 'IP' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                  </a>
                </th>
                <th>
                  <a ng-click="order('Role')">
                    Role
                    <span ng-show="sortType == 'Role' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                    <span ng-show="sortType == 'Role' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                  </a>
                </th>
                <th>
                  <a ng-click="order('Status')">
                    Status
                    <span ng-show="sortType == 'Status' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                    <span ng-show="sortType == 'Status' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                  </a>
                </th>
              </tr>
            </thead>
            <tbody>
              <tr dir-paginate="node in (clusterNodes | filter:state.filter | orderBy:sortType:sortReverse | itemsPerPage: state.pagination_count)">
                <td>{{ node.Name }}</td>
                <td>{{ node.IP }}</td>
                <td>{{ node.Role }}</td>
                <td>
                  <i class="fa fa-heartbeat space-right green-icon"></i>
                  {{ node.Status }}
                </td>
              </tr>
              <tr ng-if="!clusterNodes">
                <td colspan="4" class="text-center text-muted">Loading...</td>
              </tr>
              <tr ng-if="clusterNodes.length === 0">
                <td colspan="4" class="text-center text-muted">No nodes available.</td>
              </tr>
            </tbody>
          </table>
          <div ng-if="clusterNodes" class="pull-left pagination-controls">
            <dir-pagination-controls></dir-pagination-controls>
          </div>
        </div>
      </rd-widget-body>
    </rd-widget>
  </div>
</div> -->
